##########################################################
# x varname
# vx varnames to check against for varname beeing unique
##########################################################
cphsoc_varname_first_char_ascii <- function(x,vx)
{
  xout <- substr(x,2,nchar(x))
  xout <- gsub('"',"'",gsub('\\s+$|_*$|^\\s+','',xout))
  xout <- paste('X',xout,sep='')
  if(is.na(match(xout,vx))) return(xout)
  
  xtmp <- substr(x,2,nchar(x))
  for(ch in LETTERS)
  {
    xout <- paste(ch,xtmp,sep='')
    if(is.na(match(xout,vx))) return(xout)
  }
  # not enough try with two letters
  for(ch1 in LETTERS)
  {
    for(ch2 in LETTERS)
    {
      xout <- paste(ch1,ch2,xtmp,sep='')
      if(is.na(match(xout,vx))) return(xout)
    }
  }
  # if unsuccessful return NA
  NA
}
